using System;

namespace JamesKovacs.Examples.ContractManager {
	/// <summary>
	/// Represents revenue on a contract recognized on a particular date.
	/// </summary>
	public class RevenueRecognition {
		#region Constructors
		/// <summary>
		/// Creates a new <see cref="RevenueRecognition"/> instance.
		/// </summary>
		/// <param name="amount">Amount recognized.</param>
		/// <param name="date"><see cref="DateTime"/> on which the revenue was recognized.</param>
		public RevenueRecognition(Money amount, DateTime date) {
			m_amount = amount;
			m_date = date;
		}
		#endregion

		#region Public methods
		/// <summary>
		/// Gets the amount.
		/// </summary>
		/// <value></value>
		public Money Amount {
			get {
				return m_amount;
			}
		}

		/// <summary>
		/// Determines whether this <see cref="RevenueRecognition"/> is recognizable by the specified <see cref="DateTime"/>.
		/// </summary>
		/// <param name="asOf"><see cref="DateTime"/> to compare to.</param>
		/// <returns>
		/// 	<c>true</c> if this <see cref="RevenueRecognition"/> is recognizable by the specified <see cref="DateTime"/>; otherwise, <c>false</c>.
		/// </returns>
		public bool IsRecognizableBy(DateTime asOf) {
			return (m_date <= asOf);
		}
		#endregion

		#region Private fields
		private Money m_amount;
		private DateTime m_date;
		#endregion
	}
}
